<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<style>
	label {width: auto;}
	.opr {margin: 3px 2px;}
	.dispose {text-decoration: line-through; color: red;}
	ul.infoshow {padding:5px 0 0 5px; overflow:auto; width: 80%;}
	ul.infoshow li {line-height: 30px; float:left; margin-right: 15px;}
	.opdisabled {text-decoration: line-through; color: #DDD; line-height: 21px;}
	td.ongoing {background-color: #99FF99; color: #333;}
	td.finished {background-color: #ddd;}
	.ps_2 {background-color: #DDD}
	.ps_3 {background-color: #99FF99}
</style>

<script>
	$(function(){
		polish_year_droplist("year_proj", 
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectYear ne null && formEntity.condVO.condProjectYear ne '' ? formEntity.condVO.condProjectYear : 'null'});
		
		polish_month_droplist("month_proj",
			${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectMonth ne null && formEntity.condVO.condProjectMonth ne '' ? formEntity.condVO.condProjectMonth : 'null'}, false);
		
		$("#month_proj").change(function(){
			if ($("#year_proj").val() == "") {
				alertMsg.error("请先选择年份....");
				$("#combox_month_proj").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
		$("#year_proj").change(function(){
			if ($("#year_proj").val() == "") {
				$("#month_proj").val("");
				$("#combox_month_proj").find("a[name='condVO.condProjectMonth']").text("所有");
			}
		});
		
		$("#export_stat_proj").click(function(){
			
			$.post("app/statistic.do?action=actionExportByProjects", {
				"condVO.condProjectYear"		: $("#year_proj").val(), 
				"projectName"					: $("#projectName").val(),
				"mgr.username"					: $("#projectMgr").val(),
				"condVO.condProjectProcess"		: $("#condProjectProcess").val(),
				"condVO.condProjectStatus"		: $("#condProjectStatus").val(),
				"condVO.condProjectAuditResult"	: $("#condProjectAuditResult").val()
			}, function(rsp){
				var feedback = eval('(' + rsp + ')');
				if (feedback.status && feedback.status == 200) 
				{
					var windowAttr = "location=yes,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no,resizable=yes,personalbar=no,scrollbars=yes"; 
					window.open("file-download?path="+feedback.file+"&filename="+feedback.name, "_blank",  windowAttr);
				} 
				else 
				{
					// error message migtht be raised here.
					alert(feedback.message);
				}
			});
		});
		
	});
	
</script>

<form id="pagerForm" method="post" action="app/statistic.do?action=pageByProjectIndex">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
</form>

<!-- SearchBar -->
<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="app/statistic.do?action=pageByProjectIndex" method="post" id="searchForm" rel="pagerForm">
		<div class="searchBar">
			<table class="searchContent" id="record_form">
				<tr>
					<td>
						<label style="float:none;">所属年份：</label>
						<select id="year_proj" name="condVO.condProjectYear" style="width: 120px">
							<option value="">所有</option>
						</select>
					</td>
					<td>
						<label style="float:none">所属月份：</label>
						<select id="month_proj" name="condVO.condProjectMonth" style="width: 120px">
							<option value="">所有</option>
						</select>
					</td>
					<td>
						<label style="float:none">登记时间：</label>
						<input class="textInput date" id="projectCreationStartTime" name="condVO.condProjectCreationStartTime" value="${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectCreationStartTime ne null ? formEntity.condVO.condProjectCreationStartTime : ''}" type="text" style="width: 70px;"/> 
						至
						<input class="textInput date" id="projectCreationEndTime" name="condVO.condProjectCreationEndTime" value="${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectCreationStartTime ne null ? formEntity.condVO.condProjectCreationEndTime : ''}" type="text" style="width: 70px;"/>
					</td>
					<td>
						<label style="float:none">项目的名称：</label>
						<input type="text" id="projectName" name="projectName" rel="pagerForm" value="${formEntity ne null ? formEntity.projectName : ''}" style="width: 120px;"/>
					</td>
					<td>
						<label style="float:none">项目负责人：</label>
						<input id="projectMgrId" name="mgr.id" value="${formEntity ne null && formEntity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
						<input id="projectMgr" type="text" name="mgr.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectManager ne null ? formEntity.projectManager.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="mgr" style="width: 120px;"/>
					</td>
				</tr>
				<tr>
					<td>
						<label style="float:none">项目进展：</label>
						<select id="condProjectProcess" name="condVO.condProjectProcess" style="width: 120px">
							<option value="">所有</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-1' ? 'selected' : ''}>项目分配</option>
							<logic:present name="processes">
								<logic:iterate name="processes" id="process">
									<option value="${process.nodeTitle}" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq process.nodeTitle ? 'selected' : ''}>${process.nodeTitle}</option>
								</logic:iterate>
							</logic:present>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectProcess eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td id="proj_status">
						<label style="float:none">项目状态：</label>
						<select id="condProjectStatus" name="condVO.condProjectStatus" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '' ? 'selected' : ''}>所有</option>
							<option value="-9" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-9' ? 'selected' : ''}>待分配</option>
							<option value="0" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '0' ? 'selected' : ''}>材料待提交</option>
							<option value="1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '1' ? 'selected' : ''}>审批中</option>
							<option value="-1" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-1' ? 'selected' : ''}>审批退回</option>
							<option value="-2" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-2' ? 'selected' : ''}>已暂停</option>
							<option value="-10" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectStatus eq '-10' ? 'selected' : ''}>审批结束</option>
						</select>
					</td>
					<td id="proj_status">
						<label style="float:none">审批结果：</label>
						<select id="condProjectAuditResult" name="condVO.condProjectAuditResult" style="width: 120px">
							<option value="" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '' ? 'selected' : ''}>所有</option>
							<option value="-9" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '-9' ? 'selected' : ''}>审批中</option>
							<option value="2" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '2' ? 'selected' : ''}>审批否决</option>
							<option value="3" ${formEntity ne null && formEntity.condVO ne null && formEntity.condVO.condProjectAuditResult eq '3' ? 'selected' : ''}>审批通过</option>
						</select>
					</td>
					<td>
						<label style="float:none">项目登记人：</label>
						<input id="projectRecorderId" name="recorder.id" value="${formEntity ne null && formEntity.projectRecorder ne null ? entity.projectRecorder.id : ''}" type="hidden"/>
						<input id="projectRecorder" type="text" name="recorder.username" rel="pagerForm" value="${formEntity ne null && formEntity.projectRecorder ne null ? formEntity.projectRecorder.username : ''}" postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="recorder" style="width: 120px;"/>
					</td>
				</tr>
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="button" id="export_stat_proj">导出</button></div></div></li>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				</ul>
			</div>
		</div>
		<input type="hidden" name="currentindex" id="currentindex" value="${currentindex ne null ? currentindex : 0}" />
	</form>
</div>

<!-- Body -->
<div class="pageContent">
	<table class="table" width="100%" layoutH="148">
		<thead>
			<tr>
				<th align="center">序号</th>
				<th align="center">项目编号</th>
				<th align="center">项目名称</th>
				<th align="center">项目负责人</th>
				<th align="center">项目推荐时间</th>
				<th align="center">行业类别</th>
				<th align="center">合作方名称</th>
				<th align="center">项目进展</th>
				<th align="center">项目状态</th>
				<th align="center">项目登记人</th>
				<th align="center">项目登记时间</th>
				<th align="center">审批结果</th>
			</tr>
		</thead>
		<tbody>
			<logic:present name="datagrid">
				<logic:iterate name="datagrid" property="items" id="entity" indexId="idx">
					<tr ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
						<td>${idx+1}</td>
						<td style="text-align:center">${entity.projectNo}</td>
						<td style="text-align:left">${entity.projectName}</td>
						<td style="text-align:left">
							${entity.projectManager.username}
							<c:if test="${entity.currentProcess eq null && entity.projectStatus eq 1}">(未经部长分配)</c:if>
						</td>
						<td><fmt:formatDate value="${entity.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
						<td style="text-align:left">${entity.projectType.dictKey}</td>
						<td style="text-align:left">${entity.projectPartnerName ne '' ? entity.projectPartnerName : '---'}</td>
						<td>
							<c:choose>
								<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">项目分配</c:when>
								<c:when test="${entity.currentProcess ne null}">${entity.currentProcess.nodeTitle}</c:when>
								<c:when test="${entity.projectStatus eq 2 || entity.projectStatus eq 3 || entity.projectStatus eq -2}">审批结束</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td ${entity.projectStatus eq -2 ? 'style="background-color: #FF9500"' : (entity.projectStatus eq -1 ? 'style="background-color: #FFD20F"' : '')}>
							<c:choose>
								<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">待分配</c:when>
								<c:when test="${entity.projectStatus eq 0}">材料待提交</c:when>
								<c:when test="${entity.projectStatus eq 1}">审批中</c:when>
								<c:when test="${entity.projectStatus eq -1}">审批退回</c:when>
								<c:when test="${entity.projectStatus eq -2}">已暂停</c:when>
								<c:when test="${entity.projectStatus eq 2 || entity.projectStatus eq 3}">审批结束</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
						<td>${entity.projectRecorder ne null ? entity.projectRecorder.username : '---'}</td>
						<td><fmt:formatDate value="${entity.projectCreationTime}" type="date" pattern="yyyy-MM-dd"/></td>
						<td class="ps_${entity.projectStatus}">
							<c:choose>
								<c:when test="${entity.projectStatus eq 2}">否决</c:when>
								<c:when test="${entity.projectStatus eq 3}">通过</c:when>
								<c:when test="${entity.projectStatus ne -2}">审批中</c:when>
								<c:otherwise>---</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
	
	<!-- Pagination -->
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
				<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
				<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
				<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
			</select>
			<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
		</div>
		<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>
	</div>
</div>

